/**
 * Copyright (c) Daniel Centore
 *
 * ex: set filetype=java expandtab tabstop=4 shiftwidth=4 :
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation.
 */
package ronp.anim.gui;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import ronp.anim.data.filmstrip.Layer;

/**
 * Keeps track of the currently active frame/layer
 * 
 * @author Daniel Centore
 *
 */
public class SelectedState
{
	private Layer activeLayer; // The active layer
	private int activeFrame; // The active frame
	private Color activeColor;
	private List<SelectedStateListener> stateListeners;

	public SelectedState()
	{
		stateListeners = new ArrayList<SelectedStateListener>();
		activeColor = Color.black;
	}

	/**
	 * @return The currently active layer
	 */
	public Layer getActiveLayer()
	{
		return activeLayer;
	}

	/**
	 * Sets the active layer
	 * @param activeLayer Layer to set it to
	 */
	public void setActiveLayer(Layer activeLayer)
	{
		this.activeLayer = activeLayer;

		for (SelectedStateListener l : stateListeners)
			l.activeLayerChanged();
	}

	/**
	 * @return The active frame
	 */
	public int getActiveFrame()
	{
		return activeFrame;
	}

	/**
	 * Sets the active frame
	 * @param activeFrame The frame to set it to
	 */
	public void setActiveFrame(int activeFrame)
	{
		this.activeFrame = activeFrame;

		for (SelectedStateListener l : stateListeners)
			l.activeFrameSet();
	}

	/**
	 * Registers a listener of state changes
	 * @param list The {@link SelectedStateListener}
	 */
	public void registerStateListener(SelectedStateListener list)
	{
		stateListeners.add(list);
	}

	/**
	 * @return The current {@link Color}
	 */
	public Color getActiveColor()
	{
		return activeColor;
	}

	/**
	 * Sets the active {@link Color}
	 * @param activeColor {@link Color} to set it to
	 */
	public void setActiveColor(Color activeColor)
	{
		this.activeColor = activeColor;
	}

}
